home *** CD-ROM | disk | FTP | other *** search
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.net.Socket;
- import java.net.UnknownHostException;
- import vrml.BaseNode;
- import vrml.Browser;
- import vrml.Event;
- import vrml.field.ConstSFRotation;
- import vrml.field.SFNode;
- import vrml.field.SFVec3f;
- import vrml.node.Node;
- import vrml.node.Script;
-
- public class ExampleClient extends Script {
- public static final int PORT = 4130;
- public static final String HOST = "localhost";
- Socket socket;
- // $FF: renamed from: in java.io.DataInputStream
- DataInputStream field_0;
- DataOutputStream out;
- // $FF: renamed from: b vrml.Browser
- Browser field_1;
- Node target;
- SFVec3f trans;
- float[] coord;
- float[] rotation;
-
- public void initialize() {
- this.field_1 = ((BaseNode)this).getBrowser();
- this.target = (Node)((SFNode)((Script)this).getField("target")).getValue();
- this.trans = (SFVec3f)this.target.getExposedField("translation");
- this.coord = new float[3];
- this.rotation = new float[4];
-
- try {
- this.socket = new Socket("localhost", 4130);
- this.field_0 = new DataInputStream(this.socket.getInputStream());
- this.out = new DataOutputStream(this.socket.getOutputStream());
- } catch (UnknownHostException var1) {
- this.field_1.setDescription("Unknown host: localhost");
- } catch (Exception var2) {
- this.field_1.setDescription("Connection error");
- }
- }
-
- public void processEvent(Event var1) {
- ((ConstSFRotation)var1.getValue()).getValue(this.rotation);
-
- try {
- this.trans.getValue(this.coord);
- this.out.writeFloat(this.rotation[3]);
- this.out.writeFloat(this.coord[0]);
- this.out.writeFloat(this.coord[1]);
- this.out.writeFloat(this.coord[2]);
- this.coord[0] = this.field_0.readFloat();
- this.coord[1] = this.field_0.readFloat();
- this.coord[2] = this.field_0.readFloat();
- this.field_1.setDescription("position: " + this.coord[0] + "," + this.coord[1] + "," + this.coord[2]);
- this.trans.setValue(this.coord);
- } catch (IOException var3) {
- this.field_1.setDescription("IOException: " + var3);
- }
- }
-
- public void shutdown() {
- try {
- this.out.close();
- this.field_0.close();
- this.socket.close();
- } catch (Exception var1) {
- this.field_1.setDescription("Connection close error");
- }
- }
- }
-